// SlagCar/DriverRegisterList/DriverRegisterList.js
let listBehavior = require('../../behavior/list')
Page({

  behaviors: [ listBehavior, ],
  /**
   * 页面的初始数据
   */
  data: {
    system_id: 1164, //方通系统号1164

    filterList: ['全部','审核中','已审核'],
    filter: '全部',
    baseQuery: [],

    page: 1,
    total: 0,
    limit: 10,
    list: [],

  },
  //查询过滤数据
  bindFilter(e){
    let {name} = e.currentTarget.dataset;
    this.setData({filter: name,page: 1});
    this.getFirstPage();
  },

  //获取数据
  getDataList(){
    let {page,limit,filter,list,baseQuery,system_id} = this.data
    let total = 0,
      obj = {};
    let url =`ZT/DriverRegistration/${system_id}`,
      post = {['page.no']: page,['page.size']:limit,'orderBy':'row_id desc'},
      where = [...baseQuery];

    if (filter === '审核中'){post.is_Checked = false;}
    if (filter === '已审核'){ post.is_Checked = true;}
    // if (where.length) post.SearchWhere = where;
    wx.$get(5,url,post).then(res => {
      if (res.errcode != 0) return;
      if (res.data.row){
        total = res.page.totalsize;
        let rows = res.data.row;
        if(page !== 1) rows = [ ...list,...rows, ]
        obj = {total,list: rows,page};
      }
      this.setData(obj);
    });
  },

  navTo(e){
    let {url} = e.currentTarget.dataset;
    wx.navigateTo({url})
  },


  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.getDataList();
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})
